let txt = document.querySelector('.txt')
let prompt = document.querySelector('.prompt')
let max = 40
//keyup键盘按键松开事件
txt.addEventListener('keyup', function () {
    let num = max - txt.value.trim().length
    console.log(txt.value);
    if (num <= 0) {
        num = 0
        txt.setAttribute('disabled', 'disabled')
        prompt.innerHTML = `还可以输入${num}个字符`
        return
    }
    prompt.innerHTML = `还可以输入${num}个字符`
})